package com.xiaolun.controller;

import com.xiaolun.mapper.OrderMapper;
import com.xiaolun.pojo.Order;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
public class OrderUpdate {

    @Autowired
    private OrderMapper orderMapper;

    @RequestMapping(value = "/update",method = RequestMethod.POST)
    @ResponseBody
    public String login(@RequestBody Order order) {

        if (order.getId() != 0) {
            int result = this.orderMapper.updateOrder(order);
            System.out.println("result的值：" + result);
            if (result != 0) {
                return "ok"; //添加成功
            } else {
                return "error";
            }
        } else {
            System.out.println("更新的属性id值为0");
            return "error";
        }
    }
}
